/******************************************************************************
 Copyright (c) 2019-2024 Qualcomm Technologies International, Ltd.
 All Rights Reserved.
 Qualcomm Technologies International, Ltd. Confidential and Proprietary.

******************************************************************************/
#ifndef __CSR_BT_TD_DB_GATT_H_
#define __CSR_BT_TD_DB_GATT_H_

#include "csr_synergy.h"
#include "csr_types.h"
#include "csr_bt_addr.h"
#include "csr_bt_td_db.h"
#include "csr_bt_profiles.h"
#include "csr_bt_gatt_prim.h"


#ifdef __cplusplus
extern "C" {
#endif

/* Logical TDDB key used to store information to PS in CsrBtTdDbGattInfo format.*/
#define CSR_BT_TD_DB_GATT_KEY_GATT_INFO                     0

#define CSR_BT_TD_DB_GATT_CONFIG_INDICATE_SERVICE_CHANGE    (1 << 0)
#define CSR_BT_TD_DB_GATT_CONFIG_PEER_SERVICE_UNCHANGED     (1 << 1)

/* Stores the information which are required for GATT module to function.
 * This is represented by TDDB key CSR_BT_TD_DB_GATT_KEY_GATT_INFO.*/
typedef struct
{
    CsrUint8                config;                     /* Reserved for future use */
    CsrUint32               localDbVersion;             /* Reserved for future use. */
    CsrBtGattHandle         serviceChange;              /* This is used to persist service change indication handle to
                                                         * enable the Service change CCD's for GATT caching client */
    CsrBtGattHandle         serviceChangeClientConfig;  /* This is used to persist Service change state for GATT caching
                                                         * client to decide to enable service change indication to the remote */
#if defined(CSR_BT_GATT_CACHING) || defined (CSR_BT_GATT_INSTALL_EATT) || (!defined(EXCLUDE_GATT_GAP_ENCRYPTED_DATA_KEY_MATERIAL))
    CsrBtGattFeatureInfo    gattSuppFeatInfo;           /* Used to persist GATT specific feature information
                                                         * e.g. Client supported feature, Server supporrted feature bit,
                                                         * encrypted key data material */
#endif
#ifdef CSR_BT_INSTALL_LE_PRIVACY_1P2_SUPPORT
    CsrUint8                carValue;                   /* Used to persist CENTRAL_ADDRESS_RESOLUTION_CHARAC value. */
#endif /* CSR_BT_INSTALL_LE_PRIVACY_1P2_SUPPORT */
} CsrBtTdDbGattInfo;


CSR_BT_TD_DB_KEY_STRUCT_COMPILE_ASSERT(CsrBtTdDbGattInfo);

#define CsrBtTdDbSetGattInfo(_addressType, _deviceAddr, _gattInfo)              \
        CsrBtTdDbWriteEntry(_addressType,                                       \
                            _deviceAddr,                                        \
                            CSR_BT_TD_DB_SOURCE_GATT,                           \
                            CSR_BT_TD_DB_GATT_KEY_GATT_INFO,                    \
                            sizeof(CsrBtTdDbGattInfo),                          \
                            _gattInfo)
    
#define CsrBtTdDbGetGattInfo(_addressType, _deviceAddr, _gattInfo)              \
        CsrBtTdDbGetEntry(_addressType,                                         \
                          _deviceAddr,                                          \
                          CSR_BT_TD_DB_SOURCE_GATT,                             \
                          CSR_BT_TD_DB_GATT_KEY_GATT_INFO,                      \
                          sizeof(CsrBtTdDbGattInfo),                            \
                          _gattInfo)
#ifdef __cplusplus
}
#endif

#endif /* __CSR_BT_TD_DB_GATT_H_ */
